<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>搜索功能测试</title>
    <script src="/static/js/api-client.js" defer></script>
    <script src="/static/js/search-manager.js" defer></script>
</head>
<body>
    <div class="container">
        <h1>搜索功能测试</h1>
        
        <!-- 搜索类型选择 -->
        <div class="mb-4">
            <div class="flex space-x-4">
                <label class="inline-flex items-center">
                    <input type="radio" name="searchType" value="semantic" class="form-radio" checked>
                    <span class="ml-2">语义搜索</span>
                </label>
                <label class="inline-flex items-center">
                    <input type="radio" name="searchType" value="regex" class="form-radio">
                    <span class="ml-2">传统搜索(支持正则)</span>
                </label>
            </div>
        </div>
        
        <!-- 搜索输入 -->
        <div class="mb-4">
            <label class="block text-gray-700 text-sm font-bold mb-2" for="searchQuery">
                搜索查询
            </label>
            <input type="text" id="searchQuery" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" placeholder="输入您要搜索的内容...">
        </div>
        
        <!-- 搜索选项 -->
        <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
            <div>
                <label class="block text-gray-700 text-sm font-bold mb-2" for="searchLimit">
                    结果数量限制
                </label>
                <input type="number" id="searchLimit" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" value="10" min="1" max="100">
            </div>
            <div>
                <label class="block text-gray-700 text-sm font-bold mb-2" for="searchThreshold">
                    相似度阈值
                </label>
                <input type="number" id="searchThreshold" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" value="0.5" min="0" max="1" step="0.1">
            </div>
        </div>
        
        <!-- 高级选项 -->
        <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-4">
            <div>
                <label class="block text-gray-700 text-sm font-bold mb-2" for="fileTypes">
                    文件类型（逗号分隔）
                </label>
                <input type="text" id="fileTypes" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" placeholder="例如：.md,.txt,.go">
            </div>
            <div>
                <label class="flex items-center">
                    <input type="checkbox" id="enableDedup" class="mr-2 leading-tight">
                    <span class="text-gray-700 text-sm font-bold">结果文件去重归纳</span>
                </label>
                <p class="text-xs text-gray-500 mt-1">启用后，同一文件只显示一次，并显示匹配次数</p>
            </div>
            <div id="dedupMultiplierContainer" class="hidden">
                <label class="block text-gray-700 text-sm font-bold mb-2" for="dedupMultiplier">
                    检索倍数
                </label>
                <input type="number" id="dedupMultiplier" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" value="100" min="10" max="1000" step="10">
                <p class="text-xs text-gray-500 mt-1">去重时扩大检索的倍数，值越大结果越全面</p>
            </div>
        </div>
        
        <!-- 搜索按钮 -->
        <div class="mb-6">
            <button id="searchBtn" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
                <i class="fas fa-search mr-2"></i>搜索
            </button>
        </div>
        
        <!-- 搜索结果 -->
        <div id="searchResults" class="hidden">
            <h4 class="font-bold text-gray-800 mb-2">搜索结果</h4>
            <div id="searchResultsContent" class="space-y-4"></div>
        </div>
    </div>
    
    <script>
        // 简单的测试脚本
        document.addEventListener('DOMContentLoaded', function() {
            console.log('DOM内容已加载');
            
            const searchBtn = document.getElementById('searchBtn');
            if (searchBtn) {
                console.log('找到搜索按钮，添加点击事件');
                searchBtn.addEventListener('click', function() {
                    console.log('搜索按钮被点击了！');
                    alert('搜索按钮点击事件正常工作！');
                });
            } else {
                console.error('未找到搜索按钮');
            }
        });
    </script>
</body>
</html>